package com.dayuanit.dy15.atm.controller;

import com.dayuanit.dy15.atm.entity.AtmUser;
import com.dayuanit.dy15.atm.exception.BizException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * @author echo
 * @date 2020/5/23 - 14:32
 */
public abstract class BaseController {

    protected long getUserId(HttpServletRequest request) {
        HttpSession session = request.getSession();
        AtmUser user = (AtmUser) session.getAttribute("loginUser");
        if (null == user) {
            throw new BizException("请先登录");
        }
        return user.getId();

//        return 1004L;
    }
}
